<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <meta name="layout" content="main" />
    <title>Burn Down Table: ${project.name} </title>
  </head>
  <body>
    <div class="nav">
      <span class="menuButton"><a class="home" href="${createLink(uri: '/pspData')}">PSP Data</a></span>
    </div>
    <div>
      <br />
      <h1>Burn Down Table</h1>
      <h2>Project: ${project.name}</h2>
      <h3>
        Start date: <g:formatDate format="dd MMMM yy" date="${project.startDate}" /> <br />
        End date: <g:formatDate format="dd MMMM yy" date="${project.endDate}" /></h3>
      <g:if test="${session.project}">
        <div class="list">
          <table>
            <thead>
              <tr class="center">
                <th rowspan="2">No.</th>
                <th rowspan="2">Day</th>
                <th rowspan="2">Date</th>
                <th rowspan="2">Task</th>
                <th rowspan="2">Description</th>
                <th rowspan="2">Plan Value</th>
                <th colspan="${session.projectTeams.size() + 1}">Earn Value</th>
                <th style="border-left: solid 2px;" colspan="${session.projectTeams.size() + 2}"">Balance</th>
              </tr>
              <tr>
            <g:each in="${session.projectTeams}" status="j" var="projectTeam">
              <th>${projectTeam.user.username}</th>
            </g:each>
            <th>Average</th>
            <th style="border-left: solid 2px;">Planned</th>
            <g:each in="${session.projectTeams}" status="j" var="projectTeam">
              <th>${projectTeam.user.username}</th>
            </g:each>
            <th>Average</th>
            </tr>
            </thead>
            <tbody>
<% for (int i = 0; i < projectRange; i++) { %>
              <tr class="${dateList.get(i).getDay() == 3? 'week': ((i % 2) == 0 ? 'odd' : 'even')}">
                <td>${noList.get(i)}</td>
                <td><g:formatDate format="EEEE" date="${dateList.get(i)}" /></td>
            <td><g:formatDate format="dd MMMM yyyy" date="${dateList.get(i)}" /></td>
            <td>${taskList.get(i)?.name}</td>
            <td>${taskList.get(i)?.description}</td>
            <td><g:formatNumber number="${planList.get(i)}"  format="###,##0" /></td>
            <g:each in="${burnDownList}" status="k" var="burnDown">
              <td><g:formatNumber number="${burnDown.get(i)}"  format="###,##0" /></td>
            </g:each>
            <td><g:formatNumber number="${avgBurnDownList.get(i)}"  format="###,##0" /></td>
            <td style="border-left: solid 2px;"><g:formatNumber number="${plannedList.get(i)}"  format="###,##0.##" /></td>
            <g:each in="${teamBalanceList}" status="k" var="balance">
              <td><g:formatNumber number="${balance.get(i)}"  format="###,##0" /></td>
            </g:each>
            <td><g:formatNumber number="${avgBalanceList.get(i)}"  format="###,##0" /></td>
            </tr>
  <% } // end for %>
            </tbody>
          </table>
        </div>
        <br />
      </g:if>
    </div>
  </body>
</html>
